<?php

namespace App\Http\Controllers\Index;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;

class IndexController extends Controller
{
    public function index()
    {
        return redirect('/viewLogin');
    }

    public function login(Request $request)
    {
        $data = $request->all();

        $validator = Validator::make($data, [
            'admin'      => ['required'],
            'password'   => ['required']
        ]);

        if ( $validator->fails() )
        {
            dd($validator->errors());
        }
    }

    public function register(Request $request)
    {
        $data = $request->all();

        $validator = Validator::make($data, [
            'signname'      => ['required'],
            'email'         => ['required'],
            'password'      => ['required'],
            'repassword'    => ['required']
        ]);

        if ( $validator->fails() )
        {

        }

        return view('errors.403');
    }

    public function viewLogin()
    {
        return view('index.login');
    }

    public function viewRegister()
    {
        return view('index.register');
    }
}
